package com.fanrenqiji.entity;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;

import javax.persistence.*;

import java.sql.Timestamp;

/**
 * Created by yanwt on 2017/4/8.
 */
@Getter
@Setter
@Entity
@Table(name = "tb_system_message")
@org.hibernate.annotations.Table(appliesTo = "tb_system_message", comment = "系统通知")
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate
@org.hibernate.annotations.Cache(region="system_message", usage = CacheConcurrencyStrategy.READ_WRITE)
public class SystemMessageEntity extends DataEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name="parent_id",columnDefinition="bigint(20) default null comment '家长ID'")
    private Long parentId;
    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "parent_id",insertable = false,updatable = false, columnDefinition = ("bigint(20) default null comment '家长ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause = "del_flag=" + DEL_FLAG_NORMAL)
    private ParentEntity parent;

    @Column(name="teacher_id",columnDefinition="bigint(20) default null comment '老师ID'")
    private Long teacherId;
    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name="teacher_id",insertable = false,updatable = false,columnDefinition=("bigint(20) default null comment '老师ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause="del_flag="+DEL_FLAG_NORMAL)
    private TeacherEntity teacher;

    @Column(name="open_id",columnDefinition="varchar(50) not null comment 'open_id'")
    private String openId;

    @Column(name="title",columnDefinition="varchar(200) not null comment '标题'")
    private String title;
    @Column(name="content",columnDefinition="text not null comment '内容'")
    private String content;

    @Column(name="status",columnDefinition = ("int(1) not null comment '状态 0:未读，1:已读'"))
    private int status;

    @Column(name="read_time",columnDefinition="datetime default null comment '阅读时间'")
    private Timestamp readTime;

}
